import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import '@/assets/css/reset.scss'
import api from './api/index'
Vue.prototype.$request = api
import utils from '@/assets/js/utils';
Vue.prototype.$utils = utils;
import vcolorpicker from 'vcolorpicker'
Vue.use(vcolorpicker)
// import VueHtml5Editor from 'vue-html5-editor'
// Vue.use(VueHtml5Editor, {name: "vue-html5-editor",showModuleName: false});
Vue.config.productionTip = false
import VmScrollbar from 'vue-multiple-scrollbar'
Vue.component(VmScrollbar.name, VmScrollbar)
// import { Dialog } from 'vant';
// import KFormDesign from 'k-form-design'
// import 'k-form-design/lib/k-form-design.css'
// Vue.use(KFormDesign)

// //引入插件核心文件
// import VueQuillEditor from 'vue-quill-editor'
// //引入插件样式
// import 'quill/dist/quill.core.css'
// import 'quill/dist/quill.snow.css'
// import 'quill/dist/quill.bubble.css'
import { Image as VanImage,Popup,Button,Icon,Form,Field,Uploader,Cell,Calendar,DatetimePicker,Switch,ActionSheet,Tab,Tabs,List,Toast,Loading,Pagination,Empty,Grid,GridItem } from 'vant';
Vue.use(VanImage).use(Popup).use(Button).use(Icon).use(Form).use(Field).use(Uploader).use(Cell)
.use(Calendar).use(DatetimePicker).use(Switch).use(ActionSheet).use(Tab).use(Tabs).use(List)
.use(Toast).use(Loading).use(Pagination).use(Empty).use(Grid).use(GridItem);


// 添加请求拦截器
axios.interceptors.request.use(
  config=>{
    Toast.loading({
      duration: 0, // 持续展示 toast
      message: '加载中...',
      loadingType: 'spinner',
    });
      return config // return是为了继续向下传递, promise链式传递
  },
  error=>{
      return Promise.reject(error)// return Promise 是为了把错误继续向下传递
  })
// 拦截器2先执行
axios.interceptors.response.use(
  response =>{
       Toast.clear();
       return response
  },
  function(error){
      Toast.fail('加载失败！');
      Toast.clear();
      return Promise.reject(error)
  }
)

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
